package com.mg.game.content.gamescreen;

import java.util.Random;

import com.mg.framework.tiled.Map;
import com.mg.game.content.CollisionDetection;
import com.mg.game.content.TankGameAssets;

public class TankManager {

	private PlayerTank playerTank;

	public PlayerTank getPlayerTank() {
		return playerTank;
	}

	private GameActor[] eTanks;
	private GameScreen gameScreen;
	private Map map;

	public TankManager(GameScreen gameScreen, Map map) {
		this.gameScreen = gameScreen;
		this.map = map;
		GameActor.setCollisionDetection(new CollisionDetection(map));
		this.createPlayerTank();
		this.createETank();
	}

	private void createPlayerTank() {
		this.playerTank = new PlayerTank(this.gameScreen,
				TankGameAssets.playerTank,
				map.getMapObject("tankLayer", "tank"));
	}

	private void createETank() {
		this.eTanks = new GameActor[20];
		Random random = new Random();
		for (int i = 0; i < eTanks.length; i++) {
			switch (Math.abs(random.nextInt()) % 3) {
			case 0:
				this.eTanks[i] = new FastTank(this.gameScreen,
						TankGameAssets.fastTank, map.getMapObject("etkLayer",
								"a" + (Math.abs(random.nextInt()) % 3)));
				break;
			case 1:
				this.eTanks[i] = new SolidTank(this.gameScreen,
						TankGameAssets.solidTank, map.getMapObject("etkLayer",
								"a" + (Math.abs(random.nextInt()) % 3)));
				break;
			case 2:
				this.eTanks[i] = new LuckyTank(this.gameScreen,
						TankGameAssets.luckyTank, map.getMapObject("etkLayer",
								"a" + (Math.abs(random.nextInt()) % 3)));
				break;
			}
		}
	}
}
